package com.spring.springboot.config;

import com.spring.springboot.dto.User;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;


/**
 * 项目名称: java_algorithm
 * @ClassName MyBeanPostProcess
 * @Description
 * @Author huipanxing huipanxing@chinasofti.com   @Date 2022/5/13 14:18
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof User){
            ((User) bean).setId("1");
            ((User) bean).setName("xiaohuihui");
            System.out.println();
        }
        return bean;
    }
}
